package com.darren.framework.dao.impl;

import org.hibernate.Session;
import org.hibernate.query.Query;
import org.springframework.stereotype.Repository;

import com.darren.framework.dao.UserDao;
import com.darren.framework.entity.User;


@Repository
public class UserDaoImpl extends GenericDaoImpl<User, Long> implements UserDao {

	@Override
	public User findByUserAcountOrMobile(String queryString) {
		Session session  = sessionFactory.getCurrentSession();
		Query<User> query = (Query<User>) session.createQuery(" from User where userAccount = :userAccount or mobile = :mobile ",User.class);
		query.setParameter("userAccount", queryString);
		query.setParameter("mobile", queryString);
		return query.uniqueResult();
	}

}